package com.wg.net.client.core;

import java.net.URI;

/**
 * 客户端配置
 *
 * @author 少爷123
 */
public class ClientConfig {
    private final URI uri;
    private String appId;

    public ClientConfig(URI uri, String appId) {
        this.uri = uri;
        this.appId = appId;
    }

    public String getUrl() {
        return this.uri.toString();
    }

    /**
     * 加密验证
     */
    public boolean isSsl() {
        String scheme = this.uri.getScheme();
        return "wss".equalsIgnoreCase(scheme) || "https".equalsIgnoreCase(scheme);
    }

    @Override
    public String toString() {
        return getUrl();
    }

    public String getIp() {
        return this.uri.getHost();
    }

    public int getPort() {
        return this.uri.getPort();
    }

    public URI getUri() {
        return uri;
    }

    public String getAppId() {
        return appId;
    }
}
